#include <iostream>

using namespace std;

const int N = 300;
using ll = long long;
int cnt[N], v[N];
ll n, m;
// 现在直接使用空间优化的版本，来解决这个问题
const int M = 1e6 + 10;
ll f[M];
int main()
{
    // zdl:: 现在要试着仔细分子这道提高题目的题意！！
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> cnt[i];
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        cin >> v[i], sum += v[i] * cnt[i];

    f[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = sum; j >= 0; j--)
        {
            for (int k = 0; k <= cnt[i] && k * v[i] <= j; k++)
            {
                f[j] = max(f[j], f[j - k * v[i]] * k);
                // cout << "f[" << j << "]" << "=" << f[j] << endl;
            }
        }
    }

    // zdl:: 接下来我们开始得去结果，现在是使用这个结果
    for (int i = 0; i <= sum; i++)
    {
        if (f[i] >= m)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

